﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ETADTools.Lib
{
  public abstract class ScriptBuilder
  {
    public abstract string SqlScript { get; }
    public abstract void Build();

    protected FormInfo Info;
    public ScriptBuilder(FormInfo info)
    {
      Info = info;
    }

    protected StringBuilder BuildBasicInfo()
    {
      StringBuilder result = new StringBuilder(SqlScript);

      result.Replace(PlaceHolder.PageName, Info.PageName);
      result.Replace(PlaceHolder.PageKey, Info.PageKey);
      result.Replace(PlaceHolder.PrimaryKey, Info.PrimaryKey);
      result.Replace(PlaceHolder.AuthorName, Info.AuthorName);
      result.Replace(PlaceHolder.CreationDate, Info.CreationDate);
      result.Replace(PlaceHolder.RecordType, Info.RecordType.ToString());
      result.Replace(PlaceHolder.TableName, Info.TableName);
      result.Replace(PlaceHolder.TableAlias, Info.TableAlias);

      return result;
    } 
  }
}
